package org.jpro.modules.system.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.jpro.common.bean.BaseEntity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * <P>功能描述 : 角色entity </P>
 * <P>Method Name : User </P>
 * <P>Author : 王泽浩 </P>
 * <P>E-Mail : 1028625100@qq.com </P>
 * <P>Date : 2017-03-03 23:41:36</P>
 * @since 1.0
 */
@Getter
@Setter
@Entity
@ToString
@DynamicUpdate
@DynamicInsert
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "role")
public class Role extends BaseEntity<Integer> implements java.io.Serializable {

    // Fields
    private static final long serialVersionUID = 1L;

    @Column(name = "name", nullable = false, length = 20)
    private String name;

    @Column(name = "role_code", nullable = false, length = 20)
    private String roleCode;

    @Column(name = "description", length = 65535)
    private String description;

    @Column(name = "sort")
    private Short sort;

    @JsonIgnore
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "role")
    private Set<UserRole> userRoles = new HashSet<UserRole>(0);

    @JsonIgnore
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "role")
    private Set<RolePermission> rolePermissions = new HashSet<RolePermission>(0);

    // Constructors

    public Role(Integer id) {
        super(id);
    }

}